package com.tianhui.consignortwofei.mvp.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.fgs.common.CommonFragment;
import com.fgs.common.CommonModel;
import com.fgs.common.CommonPresenter;
import com.fgs.common.CommonResponse;
import com.fgs.common.CommonView;
import com.fgs.common.api.CommonConfig;
import com.fgs.common.progress.ExceptionHandle;
import com.fgs.common.progress.ObserverResponseListener;
import com.fgs.common.utils.CommonUtil;
import com.fgs.common.utils.LogUtil;
import com.fgs.common.utils.ToastUtil;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.api.OrderApiService;
import com.tianhui.consignortwofei.base.BaseActivity;
import com.tianhui.consignortwofei.constant.KeyValue;
import com.tianhui.consignortwofei.manager.EventBusManage;
import com.tianhui.consignortwofei.mvp.model.OrderModel;
import com.tianhui.consignortwofei.mvp.model.enty.DisplayPictureInfo;
import com.tianhui.consignortwofei.mvp.model.enty.FreightCalculationInfo;
import com.tianhui.consignortwofei.mvp.model.enty.GetZhuangCangBean;
import com.tianhui.consignortwofei.mvp.model.enty.OrderInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailAllPriceInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailFreightInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailFreightTipInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailItemInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailLineInfo;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailPictureInfo;
import com.tianhui.consignortwofei.mvp.ui.adapter.SaleCarAdapter;
import com.tianhui.consignortwofei.pattern.freightCalculation.CalculationController;
import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction;
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;
import com.xuexiang.xutil.common.StringUtils;

import org.yczbj.ycrefreshviewlib.inter.OnItemChildClickListener;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;

/**
 * @author fgs
 * @date 2020/9/8
 * @description
 **/
public class SaleCarFreightLookActivity extends BaseActivity {

    @BindView(R.id.activity_freight_recyclerView)
    RecyclerView mRecyclerView;
    private SaleCarAdapter mAdapter;
    private OrderInfo mOrderInfo;
    private OrderModel mOrderModel;
    private String mGrantsPrice;
    private String mOtherPrice;
    private String mServicePrice;//信息服务费
    private String mDriverPrice;//司机运费
    private String mTotalPrice;//应付运费总价格
    private String mTotalTaxPrice;//含税应付运费总价格
    private String mGrantsRemark;
    private String mDeductRemark;

    private String zcPrice;//仓储费
    private String ccPrice;//装车

    private String mYunFeiPrice;//运费价格

    @Override
    public int getLayoutId() {
        return R.layout.activity_freight;
    }

    @Override
    public CommonPresenter createPresenter() {
        return null;
    }

    @Override
    public CommonView createView() {
        return null;
    }

    @Override
    public String getToolbarTitle() {
        return "运费计算";
    }

    @Override
    public void init() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(linearLayoutManager);

        mAdapter = new SaleCarAdapter(this);
        mRecyclerView.setAdapter(mAdapter);

        Bundle bundle = getIntent().getExtras();
        if (bundle != null && !bundle.isEmpty()) {
            mOrderInfo = bundle.getParcelable(KeyValue.KEY_ORDER_INFO);
            if (mOrderInfo != null) {
                mOrderInfo.recelveweightconfirm=mOrderInfo.recelveweight;
                mAdapter.addAll(getDetailList(mOrderInfo));
            }
        }

        initListener();

        getZhuangCheCangChu();

    }



    private void initListener() {
        mAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(View view, int position) {
                switch (view.getId()) {
                    case R.id.item_detail_freight_tip_submitButton:
//                        requestOrderFreightCalculation();
                        beginUpData();
                        break;
                    case R.id.item_detail_freight_tip_cancelButton:
                        finish();
                        break;
                }
            }
        });
        mAdapter.setOnFreightInputItemListener(new SaleCarAdapter.OnFreightInputItemListener() {
            @Override
            public void onInput(String goodsPrice, String price, String grants, String otherPrice, String zhuangChePrice, String cangChuPrice) {
                mYunFeiPrice = price;
                mOrderInfo.tradprice=mYunFeiPrice;
                mGrantsPrice = grants;
                mOtherPrice = otherPrice;
                mServicePrice = CalculationController.getInstance().getServicePrice(mOrderInfo, grants + "", otherPrice + "") + "";
                mDriverPrice = CalculationController.getInstance().getDriverPrice(mOrderInfo, goodsPrice + "", price + "", grants + "", otherPrice + "",zhuangChePrice,cangChuPrice);



                zcPrice = CommonUtil.keepTwoDecimal(cangChuPrice);
                ccPrice = CommonUtil.keepTwoDecimal(zhuangChePrice);
                if (TextUtils.isEmpty(zcPrice)){
                    zcPrice = "0";
                }
                if (TextUtils.isEmpty(ccPrice)){
                    ccPrice = "0";
                }
                if (TextUtils.isEmpty(mOtherPrice)){
                    mOtherPrice = "0";
                }
                if (TextUtils.isEmpty(mGrantsPrice)){
                    mGrantsPrice = "0";
                }




                mTotalPrice = CalculationController.getInstance().getTotalPrice(mOrderInfo, goodsPrice + "", price + "", grants + "", otherPrice + "",zhuangChePrice,cangChuPrice,mServicePrice);
                mTotalTaxPrice = CalculationController.getInstance().getTotalTaxPrice(mOrderInfo, goodsPrice + "", mOrderInfo.tradtaxprice, grants + "", otherPrice + "",zhuangChePrice,cangChuPrice,mServicePrice);
//                mTotalTaxPrice = CalculationController.getInstance().getTotalTaxPrice(mOrderInfo, goodsPrice, price, grants, otherPrice);


                LogUtil.print(mTotalPrice);

                Object object = mAdapter.getAllData().get(mAdapter.getCount() - 1);
                if (object instanceof DetailFreightTipInfo) {
                    DetailFreightTipInfo freightTipInfo = (DetailFreightTipInfo) object;
                    freightTipInfo.servicePrice = CommonUtil.keepTwoDecimal(mServicePrice);
                    freightTipInfo.driverOtherPrice = TextUtils.isEmpty(mOrderInfo.driverotherpirce) ? "0" : mOrderInfo.driverotherpirce;
                    freightTipInfo.driverPrice = CommonUtil.keepTwoDecimal(mDriverPrice);
                    freightTipInfo.totalPrice = CommonUtil.keepTwoDecimal(mTotalPrice);
                    freightTipInfo.taxTotalPrice = CommonUtil.keepTwoDecimal(mTotalTaxPrice);


                    freightTipInfo.brokercommission = mOrderInfo.brokercost + "";

                    if (mRecyclerView.isComputingLayout()) {
                        mRecyclerView.post(new Runnable() {
                            @Override
                            public void run() {
                                mAdapter.notifyItemChanged(mAdapter.getCount() - 1);
                            }
                        });

                    } else {
                        mAdapter.notifyItemChanged(mAdapter.getCount() - 1);
                    }
                }


//                //总价刷新  司机价格刷新
//                Object objectZong = mAdapter.getAllData().get(mAdapter.getCount() - 3);
//                if (objectZong instanceof DetailAllPriceInfo) {
//                    DetailAllPriceInfo allPriceInfo = (DetailAllPriceInfo) objectZong;
//                    allPriceInfo.totalPrice = CommonUtil.keepTwoDecimal(mTotalPrice);
//                    allPriceInfo.driverPrice = CommonUtil.keepTwoDecimal(mDriverPrice);
//
//                    if (mRecyclerView.isComputingLayout()) {
//                        mRecyclerView.post(new Runnable() {
//                            @Override
//                            public void run() {
//                                mAdapter.notifyItemChanged(mAdapter.getCount() - 3);
//                            }
//                        });
//
//                    } else {
//                        mAdapter.notifyItemChanged(mAdapter.getCount() - 3);
//                    }
//                }

            }

            @Override
            public void onRemarkInput(String grantsRemark, String deductRemark) {
                mGrantsRemark = grantsRemark;
                mDeductRemark = deductRemark;
                LogUtil.print(mGrantsRemark);
                LogUtil.print(mDeductRemark);
            }



        });
    }

    private void beginUpData(){
        zhuangCheInit();
    }

    private void requestOrderFreightCalculation() {

        mOrderModel = new OrderModel();
        FreightCalculationInfo freightInfo = new FreightCalculationInfo();
//        freightInfo.fcprice = mOrderInfo.tradprice;
        freightInfo.fcprice = mYunFeiPrice;

        freightInfo.billno = mOrderInfo.billno;
        freightInfo.dispatchno = mOrderInfo.dispatchno;
        freightInfo.settleweight = mOrderInfo.recelveweightconfirm;
        freightInfo.settleweighttype = "";
        freightInfo.freightprice = mTotalPrice;
        if (TextUtils.isEmpty(mGrantsPrice)) {
            freightInfo.grants = "0";
        }else {
            freightInfo.grants = mGrantsPrice + "";
        }
        freightInfo.loseweight = CalculationController.getInstance().getLoseWeight(mOrderInfo);
        freightInfo.fcremarks = mGrantsRemark;
        freightInfo.fcdeductremarks = mDeductRemark;
        freightInfo.otherpirce = mOtherPrice + "";
        freightInfo.brokercommission = mOrderInfo.brokercost + "";
//        freightInfo.iserror = (mTotalPrice.equals("0") || mDriverPrice.equals("0")) ? "1" : "0";
        freightInfo.reasonableloss = CommonUtil.keepThreeDecimal(StringUtils.toFloat(CalculationController.getInstance().getReasonableWeight(mOrderInfo)) * 1000 + "");
        freightInfo.deductpirce = CalculationController.getInstance().getDeductPrice(mOrderInfo);
        freightInfo.customerno = mOrderInfo.customerno;
        freightInfo.driveruserid = mOrderInfo.driveruserid;
        freightInfo.handlingprice = CalculationController.getInstance().getServicePrice(mOrderInfo, mGrantsPrice, mOtherPrice);
        freightInfo.settleprice = mDriverPrice;
        freightInfo.driverotherpirce = CalculationController.getInstance().getDriverOtherPrice(mOrderInfo);





        //装车费仓储费判断
        freightInfo.zcfprice = zcPrice;
        freightInfo.ccfprice = ccPrice;

        if (StringUtils.toFloat(mGrantsPrice) > 1000) {
            showToast("补助金金额不能超过1000");
            return;
        }

        if (StringUtils.toDouble(mTotalPrice) == 0 || StringUtils.toDouble(mDriverPrice) == 0) {

//        if (mTotalPrice.equals("0") || mDriverPrice.equals("0")) {
            freightInfo.iserror = "1";
            freightInfo.fciserror = "1";
            if (TextUtils.isEmpty(freightInfo.fcdeductremarks)) {
                showToast("运费计算为0或者负数，备注不能为空！");
                return;
            }
        } else {
            freightInfo.iserror = "0";
            freightInfo.fciserror = "0";
        }

        try {
            Double aDouble = Double.valueOf(mOtherPrice);
            if (!TextUtils.isEmpty(mOtherPrice)&&aDouble!=0){
                if (TextUtils.isEmpty(freightInfo.fcdeductremarks)) {
                    showToast("扣除费用不为0时，备注不能为空！");
                    return;
                }
            }
        }catch (Exception e){
            LogUtil.print(e.toString());
        }



//        int  rolePosition = SharedPreferenceManager.getInstance().getRolePosition();
//        if (2== rolePosition){
            //2 销售，3物流
            freightInfo.fcstatus="0";
//        }else {
//            freightInfo.fcstatus="1";
//        }

        mOrderModel.freightModel(this, freightInfo, true, this.bindLifecycle(), new ObserverResponseListener<CommonResponse>() {
            @Override
            public void onNext(CommonResponse commonResponse) {
                if (commonResponse.getCode() == 20000) {
                    ToastUtil.showShortToast("计算完成");
                    EventBusManage.refreshOrderList();
                    finish();
//                    ActivityManager.getInstance().finishActivity(OrderDetailActivity.class);
//                    Bundle bundle = new Bundle();
//                    bundle.putInt(KeyValue.KEY_TYPE, OrderType.TYPE_FREIGHT);
//                    bundle.putParcelable(KeyValue.KEY_ORDER_INFO, mOrderInfo);
//                    openActivity(OrderDetailActivity.class, bundle);
               } else {
                    showToast(commonResponse.getMsg());
                }

            }

            @Override
            public void onError(ExceptionHandle.ResponseThrowable e) {
                showToast(e.message);
            }
        });
    }

    private void showLog(double zcP, double ccp) {
//        if (zcP>zcf||ccp>ccf){
//
//        }
        String msg="erp装车费为"+zcP+",现在为"+zcf+
                "\nerp仓储费为"+ccp+",现在为"+ccf+
                "\n确定提交吗？";
        new MaterialDialog.Builder(getContext())
                    .content(msg)
                    .positiveText("取消")
                    .negativeText("确定")
                    .onNegative(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

                            requestOrderFreightCalculation();
                        }
                    })
                    .show();

    }


    @Override
    public CommonFragment createFragment() {
        return null;
    }

    private List getDetailList(OrderInfo orderInfo) {
        List list = new ArrayList();

        DetailInfo detailInfo;
        DetailItemInfo detailItemInfo;
        DetailFreightInfo detailFreightInfo;
        DetailFreightTipInfo detailFreightTipInfo;
        DetailPictureInfo detailPictureInfo;
        DisplayPictureInfo displayPictureInfo;
        DetailLineInfo lineInfo;

        detailInfo = new DetailInfo();
//        detailInfo.title = "货源单号：" + orderInfo.billno;
//        detailInfo.topLeftText = "调度单号：" + orderInfo.dispatchno;
//        detailInfo.topRightText = "货物类型：" + orderInfo.goodstypetext;
        detailInfo.title = "货源单号：" + orderInfo.billno+
                "\n\n货权：" + orderInfo.customername+
                "\n\n发货地：" + orderInfo.deliverprovince+" "+orderInfo.delivercity+" "+orderInfo.delivercounty;
        detailInfo.topLeftText = "目的地：" + orderInfo.destinationprovince+" "+orderInfo.destinationcity+" "+orderInfo.destinationcounty;
//        detailInfo.topRightText = "货物名称：" + orderInfo.goodsdescription;


        detailInfo.infoList = new ArrayList<>();

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "姓名：";
        detailItemInfo.content = orderInfo.drivername;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "车牌号：";
        detailItemInfo.content = orderInfo.vehiclenum;
        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "联系方式：";
        detailItemInfo.content = orderInfo.drivertel;
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);


        detailInfo = new DetailInfo();

        detailInfo.spanCount = 2;
        detailInfo.infoList = new ArrayList<>();

//        detailItemInfo = new DetailItemInfo();
//        detailItemInfo.title = "装车重量：";
//        detailItemInfo.content = orderInfo.tranweight + "吨";
//        detailInfo.infoList.add(detailItemInfo);
//
//        detailItemInfo = new DetailItemInfo();
//        detailItemInfo.title = "收货重量：";
//        detailItemInfo.content = orderInfo.recelveweight + "吨";
//        detailInfo.infoList.add(detailItemInfo);

        detailItemInfo = new DetailItemInfo();
        detailItemInfo.title = "结算重量：";
//        detailItemInfo.content = orderInfo.settleweight + "吨";
        detailItemInfo.content = orderInfo.recelveweightconfirm + "吨";
        detailInfo.infoList.add(detailItemInfo);

        list.add(detailInfo);

        //线
//        lineInfo = new DetailLineInfo();
//        list.add(lineInfo);

//        detailPictureInfo = new DetailPictureInfo();
//        detailPictureInfo.title = "单据信息";
//        detailPictureInfo.isShowTitleTip = true;
//        detailPictureInfo.list = new ArrayList<>();
//
//        displayPictureInfo = new DisplayPictureInfo();
//        displayPictureInfo.title = "装车单据";
//        displayPictureInfo.imageId = orderInfo.loadingimg;
//        detailPictureInfo.list.add(displayPictureInfo);
//
//        displayPictureInfo = new DisplayPictureInfo();
//        displayPictureInfo.title = "交货单据";
//        displayPictureInfo.imageId = orderInfo.recepitbill;
//        detailPictureInfo.list.add(displayPictureInfo);
//        list.add(detailPictureInfo);


        //线
        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        detailPictureInfo = new DetailPictureInfo();
        detailPictureInfo.title = "单据信息";
        detailPictureInfo.isShowTitleTip = true;
        detailPictureInfo.list = new ArrayList<>();

        displayPictureInfo = new DisplayPictureInfo();
        displayPictureInfo.title = "装车照片";
        displayPictureInfo.imageId = orderInfo.loadingimg;
        detailPictureInfo.list.add(displayPictureInfo);

        displayPictureInfo = new DisplayPictureInfo();
        displayPictureInfo.title = "装车单据";
        displayPictureInfo.imageId = orderInfo.poundimg;
        detailPictureInfo.list.add(displayPictureInfo);


        displayPictureInfo = new DisplayPictureInfo();
        displayPictureInfo.title = "卸车照片";
        displayPictureInfo.imageId = orderInfo.unloadimg;
        detailPictureInfo.list.add(displayPictureInfo);

        displayPictureInfo = new DisplayPictureInfo();
        displayPictureInfo.title = "交货单据";
        displayPictureInfo.imageId = orderInfo.recepitbill;
        detailPictureInfo.list.add(displayPictureInfo);

        displayPictureInfo = new DisplayPictureInfo();
        displayPictureInfo.title = "仓储单据";
        displayPictureInfo.imageId = orderInfo.driverfcimg;
        detailPictureInfo.list.add(displayPictureInfo);
        list.add(detailPictureInfo);






        lineInfo = new DetailLineInfo();
        list.add(lineInfo);

        DetailAllPriceInfo allPriceInfo = new DetailAllPriceInfo();
        allPriceInfo.totalPrice="0";
        allPriceInfo.driverPrice=orderInfo.settleprice;
        allPriceInfo.tempcode5=orderInfo.tempcode5;
        allPriceInfo.yftopPrice="0";
        allPriceInfo.cctopPrice="0";
        list.add(allPriceInfo);



        detailFreightInfo = new DetailFreightInfo();
        detailFreightInfo.goodsPrice = orderInfo.goodsunitprice;
        if (TextUtils.isEmpty(orderInfo.fcprice)) {
            detailFreightInfo.tradprice = orderInfo.tradprice;
            mYunFeiPrice=orderInfo.tradprice;
        }else {
            detailFreightInfo.tradprice = orderInfo.fcprice;
            mYunFeiPrice = orderInfo.fcprice;
        }
        detailFreightInfo.grants = orderInfo.grants;
        detailFreightInfo.otherPrice = orderInfo.otherpirce;

        detailFreightInfo.goodsdescription = orderInfo.goodsdescription;
        detailFreightInfo.orderInfo = mOrderInfo;
        detailFreightInfo.driverzcf = orderInfo.driverzcf;
        detailFreightInfo.driverccf =  orderInfo.driverccf;
        list.add(detailFreightInfo);

        lineInfo = new DetailLineInfo();
        list.add(lineInfo);


//        detailFreightTipInfo = new DetailFreightTipInfo();
//        detailFreightTipInfo.orderInfo = orderInfo;
//        detailFreightTipInfo.insurePrice = orderInfo.insureprice;
//        list.add(detailFreightTipInfo);

        return list;
    }





    private void zhuangCheInit() {
        if (0==mOrderInfo.istrans) {
            Map<String, String> map = new HashMap<>();
            map.put("billno", mOrderInfo.dispatchno);
            map.put("type", "1");
            map.put("weight", mOrderInfo.recelveweight);
            map.put("remark", "");//adjustInfo.remark
            new CommonModel().subscribe(this, CommonConfig.getInstance().create(OrderApiService.class).orderConfirm(map), new ObserverResponseListener<CommonResponse>() {
                @Override
                public void onNext(CommonResponse commonResponse) {
                    if (commonResponse.getCode() == 20000) {
                        xieHuoInit();

                    } else {
                        ToastUtil.showShortToast(commonResponse.getMsg());
                    }
                }

                @Override
                public void onError(ExceptionHandle.ResponseThrowable e) {
                    ToastUtil.showShortToast(e.message);
                }
            });
        }else {
            xieHuoInit();
        }
    }

    private void xieHuoInit() {
        if (0==mOrderInfo.isrecelve){
            Map<String, String> map = new HashMap<>();
            map.put("billno", mOrderInfo.dispatchno);
            map.put("type", "2");
            map.put("weight", mOrderInfo.recelveweight);
            map.put("remark", "");//adjustInfo.remark
            new CommonModel().subscribe(this, CommonConfig.getInstance().create(OrderApiService.class).orderConfirm(map), new ObserverResponseListener<CommonResponse>() {
                @Override
                public void onNext(CommonResponse commonResponse) {
                    if (commonResponse.getCode() == 20000) {
                        try {
                            Double zcP = Double.valueOf(zcPrice);
//            if (zcP>zcf){
//                showToast("装车费不能高于"+zcf);
//                return;
//            }
                            Double ccp = Double.valueOf(ccPrice);
//            if (ccp>ccf){
//                showToast("仓储费不能高于"+ccf);
//                return;
//            }
                            if (zcP>zcf||ccp>ccf){
                                showLog(zcP,ccp);
                            }else {
                                requestOrderFreightCalculation();
                            }

                        }catch (Exception e){
                            LogUtil.print("fei",e.toString());
                        }

                    } else {
                        ToastUtil.showShortToast(commonResponse.getMsg());
                    }
                }

                @Override
                public void onError(ExceptionHandle.ResponseThrowable e) {
                    ToastUtil.showShortToast(e.message);
                }
            });
        }else {
            try {
                Double zcP = Double.valueOf(zcPrice);
//            if (zcP>zcf){
//                showToast("装车费不能高于"+zcf);
//                return;
//            }
                Double ccp = Double.valueOf(ccPrice);
//            if (ccp>ccf){
//                showToast("仓储费不能高于"+ccf);
//                return;
//            }
                if (zcP>zcf||ccp>ccf){
                    showLog(zcP,ccp);
                }else {
                    requestOrderFreightCalculation();
                }

            }catch (Exception e){
                LogUtil.print("fei",e.toString());
            }
        }


    }

    private double zcf = 0;
    private double ccf = 0;

    private void getZhuangCheCangChu() {
        Map<String, String> map = new HashMap<>();
        map.put("dispatchno", mOrderInfo.dispatchno);
//        map.put("type", "2");
//        map.put("weight", mOrderInfo.recelveweight);
//        map.put("remark", "");//adjustInfo.remark
        new CommonModel().subscribe(this, CommonConfig.getInstance().create(OrderApiService.class).getZhuangCheCangChu(map),
                new ObserverResponseListener<CommonResponse<GetZhuangCangBean>>() {
            @Override
            public void onNext(CommonResponse commonResponse) {
                if (commonResponse.getCode() == 20000) {
                    if (null!=commonResponse.getData()) {
                        GetZhuangCangBean cangBean = (GetZhuangCangBean) commonResponse.getData();
                         zcf = cangBean.getZcf();
                         ccf = cangBean.getCcf();
                        changeFourView(cangBean);
                    }else {
                        ToastUtil.showShortToast(commonResponse.getMsg());
                    }
                } else {
                    ToastUtil.showShortToast(commonResponse.getMsg());
                }
            }

            @Override
            public void onError(ExceptionHandle.ResponseThrowable e) {
                ToastUtil.showShortToast(e.message);
            }
        });
    }

    private void changeFourView(GetZhuangCangBean cangBean) {
        //总价刷新
        Object objectZong = mAdapter.getAllData().get(mAdapter.getCount() - 3);
        if (objectZong instanceof DetailAllPriceInfo) {
            DetailAllPriceInfo allPriceInfo = (DetailAllPriceInfo) objectZong;
            allPriceInfo.yftopPrice = cangBean.getZcf()+"";//CommonUtil.keepTwoDecimal(mTotalPrice)
            allPriceInfo.cctopPrice = cangBean.getCcf()+"";
            if (mRecyclerView.isComputingLayout()) {
                mRecyclerView.post(new Runnable() {
                    @Override
                    public void run() {
                        mAdapter.notifyItemChanged(mAdapter.getCount() - 3);
                    }
                });

            } else {
                mAdapter.notifyItemChanged(mAdapter.getCount() - 3);
            }
        }

    }


}
